﻿using System;

namespace AnB.Net
{
    public class Error : Exception
    {
        public enum Code
        {
            None = 0,

            ConnectFailed = 0x10,

            // packet parse exceptions
            PacketLengthExceeded = 0x20,
            PacketReadFailed,

            RequestTimeout = 0x30,

            // application level exceptions
            RuntimeException = 0x80,
            NotImplemented,
            WebRequestFailed,
        }
    
        public Error(Code code, object data)
        {
            _Code = code;
            _Data = data;
        }
        public Code ErrorCode
        {
            get
            {
                return _Code;
            }
        }
        public new object Data
        {
            get
            {
                return _Data;
            }
        }

        public override string Message
        {
            get
            {
                return base.Message + "\n" + ErrorCode + "\n" + Data;
            }
        }

        private Code _Code;
        private object _Data;
    }
}
